<template>
  <div style="padding: 20px">
    <el-form :model="form" label-width="120">
      <el-form-item label="用户名">
        <el-input v-model="form.username"></el-input>
      </el-form-item>
      <el-form-item label="密码">
        <el-input v-model="form.password" type="password"></el-input>
      </el-form-item>
      <el-form-item align="center">
        <el-button type="primary" @click="gologin">登录</el-button>
      </el-form-item>
    </el-form>
  </div>
</template>

<script>
// import { login } from "../../api/userinfo";
// import md5 from "js-md5";
import { setToken } from "../../utils/auth";
export default {
  data() {
    return {
      form: {
        username: "admin",
        password: "123456",
      },
    };
  },
  methods: {
    gologin() {
      // let data = {
      //      username: this.form.username,
      //           password: md5(this.form.password),
      // }

      // login(data).then((res)=>{
      //   console.log(res);
      //   setToken(res.data.token)

      // let token = res.data.token
      // if(token){
      // this.$router.push({ name: 'home' })
      // }else{
      // alert('用户名或密码错误')
      // }

      // })

      if (this.form.username == "admin" && this.form.password == "123456") {
       setToken('11111')
       this.$router.push({ name: "home" });
      }
    },
  },
};
</script>

<style lang="scss" scoped>
.el-form {
  width: 50%;
  margin: auto;
  padding: 45px;
  height: 450px;
  background-color: #fff;
}
</style>
